package com.bean;

import java.lang.reflect.Field;

/**
 * @author Cc
 * 2024-03-31
 */
public class Woman {
    public <P extends Animal> void sayHello(P pet) throws NoSuchFieldException, IllegalAccessException {
        Field field = pet.getClass().getDeclaredField("name");

        field.setAccessible(true);

        System.out.println("你好，" + field.get(pet));
    }
}
